<template>
	<div v-if="showReport == 1" class="content">
		<img class="done_img" src="@/assets/sucTips.png" alt="">
		<div class="done_title">恭喜您完成全部测评</div>
		<!-- <div class="reportBox">
			<div class="reportBox_main">
				<div class="reportBox_main_title">
					您的测评结果为：<div class="reportBox_main_title_statu" :class="result>1?(result>2?'statu_color3':'statu_color2'):'statu_color1'">{{result>1?(result>2?'认知损伤':'认知下降'):'认知正常'}}</div>
				</div>
				<div class="reportBox_main_listTitle">
					各项测评指标
				</div>
				<div class="reportBox_main_listLine">
					<div class="reportBox_main_listLine_l">{{scaleScoreDetailList[0].scaleNameSi+' '+scaleScoreDetailList[0].scaleName}}</div>
					<div class="reportBox_main_listLine_r" :class="scaleScoreDetailList[0].result=='正常'?'statu_color1':'statu_color3'">{{scaleScoreDetailList[0].result}}</div>
				</div>
				<div class="reportBox_main_listLine">
					<div class="reportBox_main_listLine_l">{{scaleScoreDetailList[1].scaleNameSi+' '+scaleScoreDetailList[1].scaleName}}</div>
					<div class="reportBox_main_listLine_r" :class="scaleScoreDetailList[1].result=='正常'?'statu_color1':'statu_color3'">{{scaleScoreDetailList[1].result}}</div>
				</div>
				<div class="reportBox_main_listLine">
					<div class="reportBox_main_listLine_l">{{scaleScoreDetailList[2].scaleNameSi+' '+scaleScoreDetailList[2].scaleName}}</div>
					<div class="reportBox_main_listLine_r" :class="scaleScoreDetailList[2].result=='正常'?'statu_color1':'statu_color3'">{{scaleScoreDetailList[2].result}}</div>
				</div>
				<div class="reportBox_main_listLine" v-if="scaleScoreDetailList[3]">
					<div class="reportBox_main_listLine_l">{{scaleScoreDetailList[3].scaleNameSi+' '+scaleScoreDetailList[3].scaleName}}</div>
					<div class="reportBox_main_listLine_r" :class="scaleScoreDetailList[3].result=='正常'?'statu_color1':'statu_color3'">{{scaleScoreDetailList[3].result}}</div>
				</div>

				<div class="reportBox_main_listTitle">
					测评结果
				</div>
				<div class="reportBox_main_reportExp">
					本次测评得分为<div class="reportBox_main_reportExp_highlight">{{brainHealthScore}}</div>分，<div class="reportBox_main_reportExp_highlight">{{result>1?'低于正常':'高于正常'}}</div>参考值范围。测评结果显示{{result>1?(result>2?'为认知损伤，说明您存在患有认知障碍的风险。':'为认知下降，说明您存在患有认知障碍的风险。'):(scaleScoreDetailList[0].result=='正常'?'各项认知功能正常，说明您尚不存在患有认知障碍的风险。':'认知功能基本正常，但存在主观认知下降。')}}
				</div>
			</div>
		</div> -->
		<div class="report_footer">
			<div v-on:click="goRouter" class="reportMore">点击查看报告详情 ></div>
		</div>
	</div>
</template>

<script>
import api from "@/api";
import Vue from 'vue';
import { Toast } from 'vant';
import Cookies from 'js-cookie';
import config from "@/config/index.js";
import wx from 'weixin-js-sdk'
import { addpacketstep } from '@/api/http.js'
Vue.use(Toast);
export default {
	components: {},
	name: 'miniReport',
	data() {
		return {
			scaleScoreDetailList: [],
			result: 0,
			showReport: 0,
			brainHealthScore: 0,
			qrCodeImgUrl: '',
			patientVersion: 0
		};
	},
	computed: {

	},
	async mounted() {
		this.patientVersion = Cookies.get('patientVersion');
		let params = {
			masterId: Cookies.get("masterId"),
			groupId: config.groupId
		}
		try {
			let res = await api.getListByMasterId(params);
			if (res.code == 1) {
				console.log(res)
				this.scaleScoreDetailList = res.data.scaleScoreDetailList;
				this.result = res.data.result;
				this.brainHealthScore = res.data.brainHealthScore;
				this.showReport = 1;
				this.qrCodeImgUrl = res.data.qrCodeImgUrl;
				Cookies.set("scaleScoreDetailList", JSON.stringify(res.data.scaleScoreDetailList));
			}
		} catch (e) {
			console.log(e);
		}
	},
	methods: {
		goRouter() {
			// this.$router.push({ path: '/report', query: { from: 'miniReport' } });
			//是否是微信浏览器
			// if (/(micromessenger)/i.test(navigator.userAgent)) { 
			// 	wx.miniProgram.redirectTo({
			// 	    url:'/pages/middleScreening/result/result?patientId='+Cookies.get('patientId')+'&token='+Cookies.get('token')
			// 	})
			// } else {
			// window.location.href='https://www.ainaoxingdong.com/h5/#/result?patientId='+Cookies.get('patientId')+'&token='+Cookies.get('token');
			this.$router.push({
				path: '/result',
				query: { patientId: Cookies.get('patientId'), token: Cookies.get('token') }
			})
			let url = encodeURIComponent('activity')
			addpacketstep(url).then(res => {
				console.log(res)
			})
			// }
		}
	},
	created() {
		let url = encodeURIComponent('mini-report')
		addpacketstep(url).then(res => {
			console.log(res)
		})
	}
};
</script>

<style scoped>
.content {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	overflow-y: scroll;
}

.done_img {
	width: 128px;
	height: 128px;
}

.done_title {
	margin-top: 11px;
	font-size: 18px;
	color: #333333;
	font-weight: 400;
	margin-bottom: 140px;
}

.reportBox {
	background-color: #F6F7FC;
	width: 100%;
	padding: 15px;
	box-sizing: border-box;
	padding-bottom: 85px;
}

.reportBox_main {
	background-color: #ffffff;
	border-radius: 15px;
}

.reportBox_main_rowLine {
	margin-top: 15px;
	width: 100%;
	margin-bottom: -15px;
}

.reportBox_main_title {
	color: #333333;
	font-size: 22px;
	display: flex;
	flex-direction: row;
	justify-content: flex-start;
	align-items: center;
	font-weight: 500;
	padding: 0 15px;
	padding-top: 25px;
}

.reportBox_main_title_statu {
	font-size: 25px;
}

.statu_color1 {
	color: #00BC56;
}

.statu_color2 {
	color: #FFA513;
}

.statu_color3 {
	color: #EA3131;
}

.reportBox_main_listTitle {
	font-size: 17px;
	color: #333333;
	font-weight: 500;
	padding-left: 7px;
	position: relative;
	display: flex;
	flex-direction: row;
	justify-content: flex-start;
	align-items: center;
	margin: 0 15px;
	margin-top: 28px;
	margin-bottom: 15px;
}

.reportBox_main_listTitle::after {
	content: '';
	width: 5px;
	background-color: #6791FF;
	border-radius: 4px;
	height: 15px;
	position: absolute;
	left: 0;
}

.reportBox_main_listLine {
	padding: 7px 0;
	margin: 0 15px;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid #E0E0E0;
}

.reportBox_main_reportExp {
	color: #666666;
	font-size: 15px;
	font-weight: 400;
	margin: 0 15px;
	padding: 13px 15px;
	background-color: #F9FAFF;
	border-radius: 10px;
}

.reportBox_main_reportExp_highlight {
	display: inline-block;
	color: #333333;
	font-weight: bold;
}

.qCodeBox {
	margin: 15px auto;
	width: 133px;
	height: 133px;
}

.qCodeBox img {
	width: 100%;
	height: 100%;
}

.qCodeExp {
	text-align: center;
	font-size: 13px;
	color: #333333;
	padding-bottom: 21px;
}

.report_footer {
	box-shadow: 0px -2px 10px 0px rgba(232, 232, 232, 0.5);
	background-color: #ffffff;
	padding: 15px;
	width: 100%;
	box-sizing: border-box;
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
}

.reportMore {
	text-align: center;
	padding: 9px 0;
	background-color: #4174F7;
	border-radius: 22px;
	width: 100%;
	color: #ffffff;
	font-size: 16px;
	font-weight: 400;
}

.reportBox_main_listLine {
	color: #333333;
	font-size: 14px;
}
</style>
